﻿//-----------------------------------------------------------------------
// <copyright file="OfferTests.cs" company="Transilvania University of Brasov">
//     Copyright (c) Nagy Robert. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace TestDomainModel
{
    using DomainModel;
    using DomainModel.Enums;
    using Microsoft.Practices.EnterpriseLibrary.Validation;
    using NUnit.Framework;

    /// <summary>
    /// Tests for the Offer class
    /// </summary>
    public class OfferTests
    {
        /// <summary>
        /// Gets the valid offer.
        /// </summary>
        private DTOOffer ValidOffer
        {
            get
            {
                return new DTOOffer
                {
                    Id = 1,
                    Bidder = new DTOBidder(),
                    Currency = default(ECurrency),
                    Product = new DTOProduct(),
                    Value = 12.12m
                };
            }
        }
        
        /// <summary>
        /// Tests the bidder should not be null.
        /// </summary>
        [Test]
        public void TestBidderShouldNotBeNull()
        {
            DTOOffer offer = this.ValidOffer;
            offer.Bidder = null;

            ValidationResults validationResults = Validation.Validate(offer);
            Assert.IsFalse(validationResults.IsValid);
        }

        /// <summary>
        /// Tests the product should not be null.
        /// </summary>
        [Test]
        public void TestProductShouldNotBeNull()
        {
            DTOOffer offer = this.ValidOffer;
            offer.Product = null;

            ValidationResults validationResults = Validation.Validate(offer);
            Assert.IsFalse(validationResults.IsValid);
        }

        /// <summary>
        /// Tests the offer value should not be valid.
        /// </summary>
        /// <param name="value">The value.</param>
        public void TestOfferValueShouldNotBeValid([Values(-10.1, -1, 0)] decimal value)
        {
            DTOOffer offer = this.ValidOffer;
            offer.Value = value;

            ValidationResults validationResults = Validation.Validate(offer);
            Assert.IsFalse(validationResults.IsValid);
        }

        /// <summary>
        /// Tests the offer value should be valid.
        /// </summary>
        /// <param name="value">The value.</param>
        public void TestOfferValueShouldBeValid([Values(0.01, 12, 20.3)] decimal value)
        {
            DTOOffer offer = this.ValidOffer;
            offer.Value = value;

            ValidationResults validationResults = Validation.Validate(offer);
            Assert.IsTrue(validationResults.IsValid);
        }
    }
}
